package cn.wolfcode.wolf2w.spot.controller;

import cn.wolfcode.wolf2w.common.core.domain.R;
import cn.wolfcode.wolf2w.common.security.annotation.InnerAuth;
import cn.wolfcode.wolf2w.spot.api.domain.Spot;
import cn.wolfcode.wolf2w.spot.query.SpotQuery;
import cn.wolfcode.wolf2w.spot.service.ISpotService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 景点列表 Controller
 * 
 * @author dalang
 * @date 2023-11-23
 */
@RestController
@RequestMapping("spots")
public class SpotController {
    @Autowired
    private ISpotService spotService;
    /**
     * 景点列表详情
     */
    @GetMapping("/detail/{id}")
    public R<Spot> detail(@PathVariable Long id) {
        Spot spot = spotService.getById(id);
        return R.ok(spot);
    }
    /**
     * 景点列表 列表
     */
    @GetMapping("/query")
    public R<IPage<Spot>> query(SpotQuery qo) {
        IPage<Spot> page = spotService.queryPage(qo);
        return R.ok(page);
    }
    /**
     * 景点列表 列表
     */
    @GetMapping("/list")
    public R<List<Spot>> list() {
        List<Spot> page = spotService.list();
        return R.ok(page);
    }


    /*****************************************对外暴露Fegin接口**********************************************/
    /**
     * Feign 接口
     */
    @GetMapping("/feign/list")
    public R<List<Spot>> feignList() {
        return R.ok(spotService.list());
    }
    @InnerAuth
    @GetMapping("/feign/{id}")
    public R<Spot> feignGet(@PathVariable Long id) {
        return R.ok(spotService.getById(id));
    }
}
